<template>
  <div class="app-container">
    <div class="filter-container tw-filter">
      <el-form ref="dataForm"  :model="form" label-position="right" label-width="100px" style="width: 800px; margin:0 auto;">
        <el-form-item label="AppID" prop="uni_push_app_id">
          <el-input v-model="form.uni_push_app_id" style="display:flex; width:500px" class="filter-item tw-filter-input"/>
        </el-form-item>
        <el-form-item label="AppKey" prop="uni_push_app_key">
          <el-input  v-model="form.uni_push_app_key"  class="filter-item tw-filter-input" style="width:500px"/>
        </el-form-item>
        <el-form-item label="AppSecret" prop="uni_push_app_secret">
          <el-input  v-model="form.uni_push_app_secret"  class="filter-item tw-filter-input" style="width:500px"/>
        </el-form-item>
        <el-form-item label="MasterSecret" prop="uni_push_master_secret">
          <el-input  v-model="form.uni_push_master_secret"  class="filter-item tw-filter-input" style="width:500px"/>
        </el-form-item>
      </el-form>
    </div>
    <div slot="footer">
      <el-button style="margin-left:40%;" v-waves class="filter-item tw-filter-button" @click="updateData()">保存数据</el-button>
    </div>
  </div>
</template>

<script>
import waves from '@/directive/waves' // waves directive

export default {
  directives: { waves },
  data() {
    return {
      apiPath: 'project.serviceother',
      // 表单数据
      form: {
        uni_push_app_id:'',
        uni_push_app_key:'',
        uni_push_app_secret:'',
        uni_push_master_secret:'',
      }
    }
  },
  created() {
    // 获取详情
    this.$api.getDetail({}, this.apiPath).then(response => {
      //数据处理
      for(let key in this.form){
        if(response.detail.hasOwnProperty(key)){
          this.form[key] = response.detail[key]
        }
      }
    })
  },
  methods: {
   // 保存数据
   updateData() {
     this.$refs['dataForm'].validate((valid) => {
       if (valid) {
         this.$api.edit(this.form, this.apiPath).then(response => {
           this.$message({
             message: '保存成功',
             type: 'success'
           })
         })
       }
     })
   }
   
  }
}
</script>
